﻿@using DAL.Model;
@{
    ViewBag.Title = "终端录入";
    var F = Html.F();

    DUser dUser = ViewBag.DUser;
    if (dUser == null)
    {
        dUser = new DUser();
    }

    ListItemCollection PermissionItems = new ListItemCollection(new DropDownList());
    //PermissionItems.Add("管理员", "1");
    PermissionItems.Add("酒品配送", "2");
    PermissionItems.Add("商品配送", "0");

    ListItemCollection RoleItems = new ListItemCollection(new DropDownList());
    RoleItems.Add("配送员", "3");
    RoleItems.Add("业务员", "1");
    RoleItems.Add("结算员", "4");
    RoleItems.Add("经理", "2");
}

@section body{
    @(F.Form()
        .ID("Form1")
        .LabelAlign(LabelAlign.Right)
        .MessageTarget(MessageTarget.Qtip)
        .LabelWidth(90)
        .ShowBorder(false)
        .ShowHeader(false)
        .Items(
            F.Panel()
                .ID("Panel1")
                .Title("终端录入")
                .BoxFlex(5)
                .MarginRight(5)
                .ShowBorder(false)
                .ShowHeader(false)
                .Items(
                     F.HiddenField()
                        .ID("ID")
                        .Text(dUser.ID != 0 ? dUser.ID.ToString() : "0"),
                     F.TextBox()
                         .ID("Name")
                         .Label("名称")
                         .ShowRedStar(true)
                         .Required(true)
                         .Text(dUser.Name != null ? dUser.Name : ""),
                     F.TextBox()
                        .ID("Password")
                        .Label("密码")
                        .ShowRedStar(true)
                        .Required(true)
                        .Text(dUser.Password != null ? dUser.Password : ""),
                    F.TextBox()
                        .ID("Phone")
                        .Label("电话")
                        .Text(dUser.Phone != null ? dUser.Phone : ""),
                    F.DropDownList()
                        .ID("Permission")
                        .Label("用户系统")
                        .DataTextField("Text")
                        .DataValueField("Value")
                        .DataSource(PermissionItems)
                        .SelectedValue(dUser.Permission.ToString())
                        .OnSelectedIndexChanged(Url.Action("Permission_SelectedIndexChanged"), "Permission")
                        .Required(true),
                    F.DropDownList()
                        .ID("Role")
                        .Label("用户类型")
                        .DataTextField("Text")
                        .DataValueField("Value")
                        .DataSource(RoleItems)
                        //.SelectedValue(dUser.Role.ToString())
                        .Required(true)


                )
        )
        .Toolbars(
            F.Toolbar()
                .ID("Toolbar1")
                .ToolbarAlign(ToolbarAlign.Right)
                .Position(ToolbarPosition.Bottom)
                .Items(
                    F.Button()
                        .ID("Button1")
                        .Text("保存信息")
                        .ValidateForms("Form1")
                        .OnClick(Url.Action("SaveDUser"), "Form1")
                        .ValidateMessageBox(false)
                )
        )
    )
}
